// OUTDOOR SECTION SCRIPT
//    Section: X = 2, Y = 1

// This is the special encounter script for this town.
// The states INIT_STATE and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

beginoutdoorscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
// This state called whenever this section is loaded into memory.
break;

beginstate START_STATE;
// This state is called every turn the party is in this outdoor section. 
break;

beginstate 10;
	reset_dialog();
	add_dialog_str(0,"A lone, old ferryman sits by the shore here, squinting at the far-off waters. When he hears your approach, he stands up with remarkable agility, and addresses you with a thin, cracked voice.",0);
	add_dialog_str(1,"_Well, masters, are you in need of a journey across to the eastern isles? I will deliver you for a mere sum of 100 gold._",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Pay.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(13);
	set_state_continue(12);
break;

beginstate 11;
	message_dialog("_You do not have it, I am afraid._",
	  "He bows and turns back to watch the sea.");
	block_entry(1);
break;

beginstate 12;
	message_dialog("_My apologies for wasting your time with my questions, then._",
	  "He bows and turns back to watch the sea.");
	block_entry(1);
break;

beginstate 13;
	if (coins_amount() >= 100) {
		change_coins(-1 * 100);
		set_state_continue(14);
		}
	set_state_continue(11);
break;

beginstate 14;
	message_dialog("It is a slow but peaceful ride across.","");
	block_entry(1);
	out_move_party(13,9);
break;

beginstate 15;
	reset_dialog();
	add_dialog_str(0,"The ferryman is still here, waiting for you to return.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Enter.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(16);
break;

beginstate 16;
	block_entry(1);
	out_move_party(4,2);
break;

beginstate 17;
	if (character_in_party(2802) >= 0) 
		set_state_continue(19);
	set_state_continue(18);
break;

beginstate 18;
	message_dialog("A solitary abandoned hut is here. You find nothing of interest.","");
break;

beginstate 19;
	reset_dialog();
	add_dialog_str(0,"A small, abandoned hut is here. Initially, you find nothing of interest.",0);
	add_dialog_str(1,"_Grendel's isle lies beyond, eastwards,_ says Ephon. _I've hid a small boat here for easier access._ He circles behind the hut briefly, and returns dragging a skiff behind him.",0);
	add_dialog_str(2,"_Should we go now?_",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Onward.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(20);
break;

beginstate 20;
	block_entry(1);
	out_move_party(32,30);
break;

beginstate 21;
	reset_dialog();
	add_dialog_str(0,"The boat, tied to a coastal rock formation, is waiting here. Do you return?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	choice = run_dialog(1);
	if (choice == 1)
		set_state_continue(22);
	if (choice == 2)
		end();
break;

beginstate 22;
	block_entry(1);
	out_move_party(26,30);
break;

beginstate 23;
	if (get_flag(221,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"A sickening odor blurs your sight. Grendel's fen may be a place of illusions and phantasms, but the physical strength of it is undeniably real. The very land repulses your advance.",0);
	add_dialog_str(1,"Ghostly fires light up the fog-covered landscape. Pools of murky water reflect back your images, distorted to monstrous proportions. The entire isle is as one in its lurid reds, greens, and greys.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(221,0,250);
break;

beginstate 24;
	if (get_flag(221,1) == 250)
		end();
	set_flag(221,1,250);
	message_dialog("You are assailed by the spirits of the fen.","");
	create_out_spec_enc(0);
break;

beginstate 25;
	if (get_flag(221,2) == 250)
		end();
	reset_dialog_preset_options(1);
	add_dialog_str(0,"You spot a patch of mandrake here.",0);
	choice = run_dialog(1);
	if (choice == 2) {
		set_flag(221,2,250);
		if (reward_give(370)) {
			}
		set_state_continue(26);
		}
break;

beginstate 26;
	message_dialog("The spirits of the fen do not take kindly to your thievery...","");
	create_out_spec_enc(1);
break;

beginstate 27;
break;

beginstate 28;
	reset_dialog();
	add_dialog_str(0,"You come upon a quiet, secluded grove. As you enter, there seem to be many whispers around you, but after a few moments they subside.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Wait.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(30);
	set_state_continue(29);
break;

beginstate 29;
	block_entry(1);
break;

beginstate 30;
	reset_dialog();
	add_dialog_str(0,"An airy spirit floats out of the woods, and hovers before you. It's so faint that you cannot distinguish any of its features, appearing only as a vaguely green shadow. It looks at you for a long time.",0);
	add_dialog_str(1,"Then, all of a sudden, it begins to speak. Its voice is calm and peaceful, yet somehow remote, as though it did not live in the same world as you.",0);
	add_dialog_str(2,"_Welcome, travelers. This is a place of rest and healing. If you leave something in return, we will be glad to relieve you of your pains._",0);
	add_dialog_str(3,"Do you accept their offer?",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Accept.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(32);
	set_state_continue(31);
break;

beginstate 31;
	message_dialog("The spirit bows and vanishes.","");
	block_entry(1);
break;

beginstate 32;
		if (coins_amount() < 150) {
			print_str_color("You can't afford that much.",2);	
			end();
			}
				
			else {
		run_select_a_pc(0);
		i = get_selected_pc();
		if (char_ok(i)) {
					play_sound(24);
					restore_pc(i);
					change_coins(-150);
					print_str_color("The spirits heal you.",2);	
					}
					}
break;

